<template>
	  <div class="unicom-small">
	          <img src="@/static/img/sm_logo.png" style="width: 80%;"/>
			  <view class="btn-line">
				  <wx-open-launch-weapp id="launch-btn" username="gh_5eac63f4d504"  :path="path">
				
          <script type="text/wxtag-template">
				<style>
				  .btn{
				  	width: 100%;
				  	height: 90upx;
				  	text-align: center;
				  	line-height: 90upx;
				  	font-size: 30upx;
				  	color: #FFFFFF;
				  	background-image: linear-gradient(to bottom, #A0C6FF 0%, #408CFF 100%);
				  	letter-spacing: 5px;
					border-radius: 2px;
					border: 0px;
					
				  }
				  </style>
						<button class="btn" :loading="disabled">点击进行官方实名</button>
          </script>	  
				  </wx-open-launch-weapp>
			  </view>
	      </div>
</template>

<script>
	import wx from 'weixin-js-sdk'
	
	export default {
	    name: "unicom",
	    data(){
	       return{
			   disabled:true,
	           path:''
	       }
	    },
	    async onLoad(option) {
	        let cardNumber = option.cardNumber
	        if (cardNumber == undefined || cardNumber == '' || cardNumber.length <= 3) {
	            this.$router.push({path: "/"})
	        }
	        // var url = window.location.origin+"?cardNumber="+cardNumber;
	          var url = location.href.split('#')[0];
		this.path = "pages/login/index?iccid="+cardNumber
	      this.$req.OEMSetting('/payment/unicomInit/white', {
	      	url:url
	      }).then(res => {
			  wx.config({
			      // debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印
			      appId: res.data.appid, // 必填，公众号的唯一标识
			      timestamp: res.data.timestamp, // 必填，生成签名的时间戳
			      nonceStr: res.data.nonceStr, // 必填，填任意非空字符串即可
			      signature: res.data.signature, // 必填，填任意非空字符串即可
			      jsApiList: ['showOptionMenu', 'chooseImage', 'previewImage'], // 必填，随意一个接口即可
			      openTagList: ['wx-open-launch-weapp'], // 填入打开小程序的开放标签名
			  })
			  this.disabled = false
		  })
	    
	
	      /*  wx.ready(function () {
	            var btn = document.getElementById('launch-btn');
	            btn.addEventListener('launch', function (e) {
	                // console.log('success');
	            });
	            btn.addEventListener('error', function (e) {
	                // console.log('fail', e.detail);
	            });
	        })*/
	    }
	
	}
</script>

<style>
	.unicom-small{
		 font-family: Avenir, Helvetica, Arial, sans-serif;
		
		  text-align: center;
		  color: #2c3e50;
		  height: 100%;
	}
	.btn-line{
		width: 100%;
		height: 70upx;
		position: relative;
		text-align: center;
		
	}

</style>
